/**
 * Created by IntelliJ IDEA
 *
 * @author zhengjie
 * @Date:2022/1/7 16:44
 * @Version 1.0
 */
package com.zj.ssm.service.impl;

import com.zj.ssm.mapper.StaffMapper;
import com.zj.ssm.pojo.domain.Staff;
import com.zj.ssm.pojo.domain.query.StaffQuery;
import com.zj.ssm.pojo.domain.vo.StaffVO;
import com.zj.ssm.result.AjaxResult;
import com.zj.ssm.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class StaffServiceImpl implements StaffService {

    @Autowired
    private StaffMapper staffMapper;

    @Override
    public AjaxResult queryStaff(StaffQuery query) {
        List<Staff> staffs = staffMapper.queryStaff(query);
        Long aLong = staffMapper.queryStaffTotal(query);

        HashMap<Object, Object> objectObjectHashMap = new HashMap<Object, Object>();
        objectObjectHashMap.put("currentData",staffs);
        objectObjectHashMap.put("totalCount",aLong);

        return AjaxResult.success(objectObjectHashMap);
    }

    @Override
    public AjaxResult addStaff(StaffVO staffVO) {
        int i = staffMapper.addStaff(staffVO);
        if (i>0){
            return AjaxResult.success();
        }
        return AjaxResult.fail();
    }

    @Override
    public AjaxResult getSta(Integer id) {
       StaffVO s = staffMapper.getSta(id);
        return AjaxResult.success(s);
    }

    @Override
    public AjaxResult updateSta(StaffVO staffVO) {
        int i = staffMapper.updateSta(staffVO);

        if (i>0){
            return AjaxResult.success();
        }
        return AjaxResult.fail();

    }

    @Override
    public AjaxResult updatePeo(Integer id) {
      int i = staffMapper.updatePeo(id);
        if(i>0){
            return AjaxResult.success();
        }
        return AjaxResult.fail();
    }

    @Override
    public AjaxResult peoUpdate(Integer id) {
        int i = staffMapper.peoUpdate(id);
        if(i>0){
            return AjaxResult.success();
        }
        return AjaxResult.fail();
    }



}
